#include "Functions/Hist.h"
#include "Functions/TerminalIO.h"
#include "TString.h"
#include "TVirtualPad.h"
using namespace BOSS_Afterburner::TerminalIO;

TH1D BOSS_Afterburner::Hist::CreateInvariantMassHistogram(const ReconstructedParticle& particle,
                                                          const int                    nBins)
{
  return TH1D(Form("hist_%s", particle.Name()),
              Form("Invariant mass for %s candidate;#it{M}_{%s} (GeV/#it{c}^{2});counts",
                   particle.NameLaTeX(), particle.DaughterLabel()),
              nBins, particle.PlotFrom(), particle.PlotUntil());
}

void BOSS_Afterburner::Hist::SetAxisTitles(TH1* hist, const char* xAxis, const char* yAxis,
                                           const char* zAxis, bool update)
{
  if(IsEmptyPtr(hist)) return;
  if(xAxis) hist->GetXaxis()->SetTitle(xAxis);
  if(yAxis) hist->GetYaxis()->SetTitle(yAxis);
  if(zAxis) hist->GetZaxis()->SetTitle(zAxis);
  if(update && gPad) gPad->Update();
}